package de.zainodis.commons.utils;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.view.View;
import android.view.ViewGroup;
import de.zainodis.commons.R;

public class ApplicationUtils {

   /**
    * @param context
    *           the application context for which to retrieve the version.
    * @return the version name attribute defined in your manifest; or "unknown"
    *         if undefined.
    */
   public static String getApplicationVersion(Context context) {
	 try {
	    // Determine the application version
	    return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
	 } catch (NameNotFoundException e) {
	    return context.getString(R.string.unknown);
	 }
   }

   public static View getRootView(Activity context) {
	 return ((ViewGroup) context.findViewById(android.R.id.content)).getChildAt(0);
   }
}
